﻿using System;
using System.Collections.Generic;

namespace Chimp.Core
{
    public class AppTransient : JointNode
    {
        public AppTransient ( JointNode p )
        {
            SetData ( p );
        }
        public override void WriteOutput ( )
        {
            l ( " public class " + Name + " : ChimpTransient\n    {" );
            l("public ChimpState State = null;");
            l("public " + Name + "(ChimpState s)\n{");
            l("State=s;\nOnBegin();\n}\n");
            ParseVars ( Vars );
            WriteNodes ( );
            l ( "}" );
        }

       
        public override void ParseNode ( )
        {
            Name = GetTok ( );
            Vars = new Dictionary<string, Var>();
            while ( !Eof )
            {
                string t = GetTok ( );

                switch ( t )
                {
                    case "Var":

                        VarList vl;
                        vl = GetVars ( );
                        break;
                    case "List":

                        VarList vl2;
                        vl2 = GetVars ( );
                        SetToList ( vl2 );

                        break;
                    case "Event":

                        t = GetTok ( );
                        Console.WriteLine ( "Parsing:" + t );
                        SetNode ( t, new JointBasic ( t, this ) );
                        Console.WriteLine("ET:"+PeekTok());

                        break;
                    case "End":
                        return;
                    default:
                        Console.WriteLine ( "Transient -Syntax error:" + t + "!" );
                        return;
                        break;
                }
            }

        }
    }
}